package xingkong.sys;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;

import xingkong.core.BusinessController;
import xingkong.core.IntegralController;
import xingkong.core.OrderController;
import xingkong.core.UserController;
import xingkong.intecepter.MyIntecepter;

public class SysConfig extends JFinalConfig{

	@Override
	public void configConstant(Constants arg0) {
		// TODO Auto-generated method stub
		arg0.setDevMode(true);
		PropKit.use("config.properties");
	}

	@Override
	public void configEngine(Engine arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configHandler(Handlers arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configInterceptor(Interceptors arg0) {
		// TODO Auto-generated method stub
		arg0.add(new MyIntecepter());
		
	}

	@Override
	public void configPlugin(Plugins arg0) {
		//配置数据库连接池
		DruidPlugin druidPlugin = new DruidPlugin(
				PropKit.get("jdbc.url"), 
				PropKit.get("jdbc.username"), 
				PropKit.get("jdbc.password"));
		arg0.add(druidPlugin);
		
		//配置db+record模式
		ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
		arg0.add(arp);
	}

	@Override
	public void configRoute(Routes arg0) {
		// TODO Auto-generated method stub
		arg0.add("/user",UserController.class);
		arg0.add("/integral",IntegralController.class);
		arg0.add("/order",OrderController.class);
		arg0.add("/business",BusinessController.class);
	}

}
